#ifndef PostscriptDoc_H
#define PostscriptDoc_H

#include "CxxUtils.h"

class PostscriptDoc 
{
public:
	class DocSegment 
	{
	public:
		int mStartLineNo, mEndLineNo;
		
		std::streampos mStartPos, mEndPos;
		
		DocSegment() 
		: mStartLineNo(0)
		, mEndLineNo(0) 
		, mStartPos(0)
		, mEndPos(0) {}
	};
	
	class DocumentMeta : public DocSegment
	{
	public:
		std::string mMedia;
		int mLanguageLevel;
		int mWidth;
		int mHeight;
		
		DocumentMeta() 
		: DocSegment()
		, mMedia("Letter")
		, mLanguageLevel(0)
		, mWidth(0)
		, mHeight(0)
		{}
	};
	
	class Page : public DocSegment
	{
	public:
		std::string mMedia;
		std::string mOrientation;
		int mLeft, mTop, mWidth, mHeight;
		
		Page() 
		: DocSegment()
		, mMedia("Letter")
		, mOrientation("Portrait")
		, mLeft(0)
		, mTop(0)
		, mWidth(0)
		, mHeight(0)
		{}
	};
	
protected:
	PostscriptDoc(const PostscriptDoc&);
	PostscriptDoc& operator=(const PostscriptDoc&);
	
	DocumentMeta mMeta;
	
	DocSegment mProlog;
	
	std::vector< Page > mPages;
	
public:
	PostscriptDoc();
	virtual ~PostscriptDoc();

	void load(std::istream &is);
	
	size_t getPageCount() const {
		return mPages.size();
	}
	
	const Page& getPage(size_t index) const {
		return mPages.at(index);
	}
	
	const DocumentMeta& getDocMeta() const {
		return mMeta;
	}
};

#endif // PostscriptDoc_H
